import request from '@/config/axios'

// 楼层 VO
export interface FloorVO {
  id: number // 主键
  name: string // 楼层名称
  lightOn: string // 开灯指令
  lightOff: string // 关灯指令
  ip: string // IP地址
  imageMain: string // 楼层图
}

// 楼层 API
export const FloorApi = {
  // 查询楼层分页
  getFloorPage: async (params: any) => {
    return await request.get({ url: `/zkteco/floor/page`, params })
  },

  // 查询楼层列表
  getAllFloorList: async () => {
    return await request.get({ url: `/zkteco/floor/list` })
  },

  // 查询楼层详情
  getFloor: async (id: number) => {
    return await request.get({ url: `/zkteco/floor/get?id=` + id })
  },

  // 新增楼层
  createFloor: async (data: FloorVO) => {
    return await request.post({ url: `/zkteco/floor/create`, data })
  },

  // 修改楼层
  updateFloor: async (data: FloorVO) => {
    return await request.put({ url: `/zkteco/floor/update`, data })
  },

  // 删除楼层
  deleteFloor: async (id: number) => {
    return await request.delete({ url: `/zkteco/floor/delete?id=` + id })
  },

  // 导出楼层 Excel
  exportFloor: async (params) => {
    return await request.download({ url: `/zkteco/floor/export-excel`, params })
  },

// ==================== 子表（展厅） ====================

  // 获得展厅分页
  getAreaPage: async (params) => {
    return await request.get({ url: `/zkteco/floor/area/page`, params })
  },
  // 根据楼层获取展区数据
  getAreasByFloor: async (floorId) => {
    return await request.get({ url: `/zkteco/floor/area/getAreasByFloor?floorId=`+ floorId })
  },
  // 新增展厅
  createArea: async (data) => {
    return await request.post({ url: `/zkteco/floor/area/create`, data })
  },

  // 修改展厅
  updateArea: async (data) => {
    return await request.put({ url: `/zkteco/floor/area/update`, data })
  },

  // 删除展厅
  deleteArea: async (id: number) => {
    return await request.delete({ url: `/zkteco/floor/area/delete?id=` + id })
  },

  // 获得展厅
  getArea: async (id: number) => {
    return await request.get({ url: `/zkteco/floor/area/get?id=` + id })
  },
}
